package team2.arsystem.Controller;

import java.util.ArrayList;

import android.util.Log;
import team2.arsystem.DomainObjects.Account;

/*This is the Use case controller which will handle requests related to account like: create account, login, etc. It is implemented as a Singleton.*/
public class AccountController {
	
	private static AccountController accountController=new AccountController();
	   
	 
	private AccountController() {		 
	}	

	public static AccountController getAccountController()
	 {
		return accountController;
	 }
	
	/*Gets the object of Account Class which actually performs the requested operation.*/
	 public  Account getAccountObject()
	 {
		 return Account.getAccountObj();
	 }
	
	 public String getUserName()
	 {
		 return getAccountObject().getAccountUserName();
	 }
	 
	/*The following methods invoke the appropriate method in the Account Object.*/ 
	public boolean loginUser(Object[] loginCredentials)
	{
		
		return (getAccountObject().login((String)loginCredentials[0], (String)loginCredentials[1]));
	}
	
	public boolean createNewAccount(Object[] newAccountDetails)
	{
		return (getAccountObject().createNewAccount((String)newAccountDetails[0],(String)newAccountDetails[1],(String)newAccountDetails[2],(String)newAccountDetails[3],(String)newAccountDetails[4]));
	}
	
	public boolean addNewMember(Object[] newMemberDetails)
	{
		return (getAccountObject().addNewMember((String)newMemberDetails[0],(String)newMemberDetails[1],(String)newMemberDetails[2],(String)newMemberDetails[3]));
	}
	
	public boolean editMember(Object[] memberDetails)
	{
		return (getAccountObject().editMember((String)memberDetails[0],(String)memberDetails[1],(String)memberDetails[2],(String)memberDetails[3],(String)memberDetails[4],(String)memberDetails[5]));
	}
	
	
	public ArrayList<String> getMembers()
	{
		try
		{
		return (getAccountObject().getMembers());
		}
		catch(Exception e)
		{
		  e.printStackTrace();
		  return null;
		}
	}
	
	public boolean setCurrency(Object[] currency)
	{
		
		return (getAccountObject().setCurrency((String)currency[0]));
	}
	
	public ArrayList<ArrayList<String>> viewMembers()
	{
		try
		{
		return (getAccountObject().viewMembers());
		}
		catch(Exception e)
		{
		  e.printStackTrace();
		  return null;
		}
	}
	
	public boolean logoutUser()
	{
		
		return (getAccountObject().logout());
	}
	
	
}
